package com.tjetc.controller;



import cn.hutool.log.Log;
import com.tjetc.entity.LogisticsPartner;
import com.tjetc.service.LogisticsPartnerService;
import com.tjetc.util.R;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (LogisticsPartner)表控制层
 *
 * @author makejava
 * @since 2025-09-19 10:34:25
 */
@RestController
@RequestMapping("/logisticsPartner")
public class LogisticsPartnerController {
    /**
     * 服务对象
     */
    @Resource
    private LogisticsPartnerService logisticsPartnerService;


    @GetMapping("/page")
    public R queryByPage(@RequestParam String name,Integer pageNum,Integer pageSize) {

        return R.ok(this.logisticsPartnerService.queryByPage(name, pageNum, pageSize));
    }

    @GetMapping("/findById")
    public R findById(Long id){
        return R.ok(this.logisticsPartnerService.findById(id));
    }

    @PostMapping("/update")
    public R updateById(@RequestBody LogisticsPartner logisticsPartner){
        this.logisticsPartnerService.updateById(logisticsPartner);
        return R.ok();
    }

    @PostMapping("/add")
    public R insert(@RequestBody LogisticsPartner logisticsPartner){
        this.logisticsPartnerService.insert(logisticsPartner);
        return R.ok();
    }

    @GetMapping("delete")
    public R deleteById(Long id){
        this.logisticsPartnerService.deleteById(id);
        return R.ok();
    }

    @GetMapping("/default")
    public R updateDefault(Long partnerId){

        this.logisticsPartnerService.setDefaultPartner(partnerId);
        return R.ok();
    }
}

